local file_ops = require "file_operations"

-- 测试文件名生成
print("Generated filename (date):", file_ops.buildSaveName("jpg", "img_", "date"))
print("Generated filename (random):", file_ops.buildSaveName("png", "", "random"))

-- 测试文件上传 (模拟上传)
local fake_upload_file = {
    filename = "test.txt",
    content = "This is a test file content."
}

local upload_result = file_ops.upload(fake_upload_file, "test/", "test_upload.txt")
if upload_result then
    print("Upload success:", upload_result.filepath)
    
    -- 测试文件下载
    local download_result = file_ops.download(upload_result.filepath)
    if download_result then
        print("Downloaded content:", download_result.content)
    end
    
    -- 测试文件信息获取
    local file_info = file_ops.getFileInfo(upload_result.filepath)
    if file_info then
        print("File info:")
        for k, v in pairs(file_info) do
            print(k, v)
        end
    end
    
    -- 测试文件列表
    print("Files in directory:")
    local files = file_ops.getFiles(file_ops.root_path .. "test/")
    for _, f in ipairs(files) do
        print(f.name, f.is_dir and "DIR" or "FILE", f.size)
    end
    
    -- 清理测试文件
    file_ops.unlink(upload_result.filepath)
end